﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using BaseThing.Definitions;
using BaseThing.Engine;

namespace BaseThing.Game
{
    class Player : GameObject
    {
        private GameInput m_pGameInput;
        private PlayerStates m_ePlayerState;

        public Player(GameInput l_eGameInput, Vector2 l_vPosition, Vector2 l_vOrientation, int l_iSpeed, string l_sAssetName, int l_iCols, int l_iRows, int l_iFps) :
            base(l_vPosition, l_vOrientation, l_iSpeed, l_sAssetName, l_iCols, l_iRows, l_iFps)
        {
            m_pGameInput = l_eGameInput;
            m_ePlayerState = PlayerStates.PLAYER_IDLE;
        }

        public PlayerStates PlayerState
        {
            set { m_ePlayerState = value; }
            get { return m_ePlayerState; }
        }

        public override void Update(GameTime gameTime)
        {
            m_pGameInput.Update(ref m_ePlayerState);

            switch (m_ePlayerState)
            {
                case PlayerStates.PLAYER_IDLE:
                    break;

                case PlayerStates.PLAYER_MOVE_UP:
                    this.Move(new Vector2(0, -1));
                   
                    break;

                case PlayerStates.PLAYER_MOVE_DOWN:
                    this.Move(new Vector2(0, 1));

                    break;

                case PlayerStates.PLAYER_MOVE_LEFT:
                    this.Move(new Vector2(-1, 0));

                    break;

                case PlayerStates.PLAYER_MOVE_RIGHT:
                    this.Move(new Vector2(1, 0));

                    break;
            }

            base.Update(gameTime);
        }

        public override void Draw(SpriteBatch spriteBranch)
        {
            base.Draw(spriteBranch);
        }
    }
}
